//
//  ONSOrderHeaderView.m
//  OneNineteen
//
//  Created by apple on 2019/2/26.
//  Copyright © 2019 stoneobs.qq.com. All rights reserved.
//

#import "OEOrderHeaderView.h"

@interface OEOrderHeaderView()

@property(nonatomic, strong) STLabel                     *statusLable;/**<  */
@property(nonatomic, strong) STButton                     *iconButton;/**<  */
@property(nonatomic, strong) STButton                     *titleButton;/**<  */
@end
@implementation OEOrderHeaderView
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithReuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 55 + 10;
}
#pragma mark --configSubView
- (void)configSubView{
    UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, 0,UIScreenWidth, 10)];
    line.backgroundColor = OE_GrayColor;
    [self addSubview:line];

    
    STButton * iconButton = [[STButton alloc] initWithFrame:CGRectMake(15, line.bottom + 10, 34, 34)
                                                      title:nil
                                                 titleColor:nil
                                                  titleFont:0
                                               cornerRadius:17
                                            backgroundColor:nil
                                            backgroundImage:nil
                                                      image:nil];
//    [iconButton sd_setBackgroundImageWithURL:[NSURL URLWithString:self.model.supplier_logo] forState:UIControlStateNormal];
    self.iconButton = iconButton;
    [self addSubview:iconButton];
    
    STButton * titleButton = [[STButton alloc] initWithFrame:CGRectMake(iconButton.right  +5, 0, UIScreenWidth, 34)
                                                       title:@""
                                                  titleColor:FirstTextColor
                                                   titleFont:14
                                                cornerRadius:0
                                             backgroundColor:nil
                                             backgroundImage:nil
                                                       image:nil];
    [self addSubview:titleButton];
    titleButton.centerY = iconButton.centerY;
    self.titleButton = titleButton;
    
    self.statusLable = [[STLabel alloc] initWithFrame:CGRectMake(15, 0, 75, 40)
                                                 text:@""
                                            textColor:FirstTextColor
                                                 font:15
                                          isSizetoFit:NO
                                        textAlignment:NSTextAlignmentRight];
    [self addSubview:self.statusLable];
    self.statusLable.centerY = self.titleButton.centerY;
    self.statusLable.right = UIScreenWidth - 15;
    __weak typeof(self) weakSelf =  self;
    [self.iconButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelctedHeader];
    }];
    [self.titleButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelctedHeader];
    }];
    
}
- (void)onSelctedHeader{
    if (self.onSelctedHeaderHandle) {
        self.onSelctedHeaderHandle();
    }
}
- (void)setModel:(OEOrderModel *)model{
    _model = model;
    
    [self.iconButton sd_setBackgroundImageWithURL:[NSURL URLWithString:self.model.supplier_info.supplier_logo] forState:UIControlStateNormal];
    [self.titleButton setTitle:model.supplier_info.supplier_name forState:UIControlStateNormal];
    self.statusLable.text = model.show_status;
}
@end
